home *** CD-ROM | disk | FTP | other *** search
- unit PackageExpert;
-
- interface
-
- procedure Register;
-
- implementation
-
- uses
- Dialogs, Classes, Menus, SysUtils, Forms, ExptIntf,
- EditIntf, ToolIntf, Windows, Controls;
-
- const
- ExpertName = 'Pacakge Editor Locator';
- ExpertAuthor = 'Oblong';
- MenuBarItemCaption = '&Clinic';
- MenuItemCaption = '&Show package editors';
- MenuItemKey = VK_F2;
- MenuItemShifts = [ssCtrl, ssAlt];
-
- type
- TPackageExpert = class(TIExpert)
- private
- //The menu bar item, and menu items that we will add in to app
- FMenuBarItem,
- FMenuItem: TIMenuItemIntf;
- protected
- //These are the event handlers of our new menu items
- procedure MenuItemClick(Sender: TIMenuItemIntf);
- public
- constructor Create;
- destructor Destroy; override;
- function GetName: string; override;
- function GetComment: string; override;
- function GetAuthor: string; override;
- function GetPage: string; override;
- function GetGlyph: HICON; override;
- function GetStyle: TExpertStyle; override;
- function GetState: TExpertState; override;
- function GetIDString: string; override;
- function GetMenuText: string; override;
- procedure Execute; override;
- end;
-
- { TPackageExpert }
-
- constructor TPackageExpert.Create;
- var
- FMainmenu: TIMainMenuIntf;
- begin
- inherited;
- if Assigned(ToolServices) then
- begin
- FMainMenu := ToolServices.GetMainMenu;
- if Assigned(FMainMenu) then
- try
- FMenuBarItem := FMainMenu.GetMenuItems.InsertItem(
- FMainMenu.GetMenuItems.GetItemCount-1,
- MenuBarItemCaption, '', '', 0, 0, 0, [mfEnabled, mfVisible], nil);
- FMenuItem := FMenuBarItem.InsertItem(0,
- MenuItemCaption, '', '', ShortCut(MenuItemKey, MenuItemShifts),
- 0, 0, [mfEnabled, mfVisible], MenuItemClick);
- finally
- FMainMenu.Free
- end
- end
- end;
-
- destructor TPackageExpert.Destroy;
- begin
- if Assigned(FMenuItem) then
- begin
- FMenuItem.DestroyMenuItem;
- FMenuItem := nil
- end;
- if Assigned(FMenuBarItem) then
- begin
- FMenuBarItem.DestroyMenuItem;
- FMenuBarItem := nil
- end;
- inherited;
- end;
-
- procedure TPackageExpert.Execute;
- begin
- end;
-
- function TPackageExpert.GetAuthor: string;
- begin
- Result := ExpertAuthor;
- end;
-
- function TPackageExpert.GetComment: string;
- begin
- Result := '';
- end;
-
- function TPackageExpert.GetGlyph: HICON;
- begin
- Result := 0
- end;
-
- function TPackageExpert.GetIDString: string;
- begin
- Result := GetName;
- end;
-
- function TPackageExpert.GetMenuText: string;
- begin
- Result := '';
- end;
-
- function TPackageExpert.GetName: string;
- begin
- Result := ExpertName;
- end;
-
- function TPackageExpert.GetPage: string;
- begin
- Result := '';
- end;
-
- function TPackageExpert.GetState: TExpertState;
- begin
- Result := [esEnabled];
- end;
-
- function TPackageExpert.GetStyle: TExpertStyle;
- begin
- Result := esAddIn;
- end;
-
- procedure TPackageExpert.MenuItemClick(Sender: TIMenuItemIntf);
- var
- I: Integer;
- begin
- for I := 0 to Screen.FormCount - 1 do
- if CompareText(Screen.Forms[I].ClassName, 'TPackageEditorForm') = 0 then
- Screen.Forms[I].BringToFront
- end;
-
- procedure Register;
- begin
- RegisterLibraryExpert(TPackageExpert.Create)
- end;
-
- end.